package com.kangyi.app.controller;

import com.kangyi.app.service.FeedbackService;
import com.kangyi.dto.SubmitDTO;
import com.kangyi.dto.UserPageDTO;
import com.kangyi.result.PageResult;
import com.kangyi.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Blank
 * @version 1.0
 */
@RestController
@RequestMapping("/app/feedback")
@Slf4j
@Api(tags = "反馈相关接口")
public class FeedbackController {

    @Autowired
    private FeedbackService feedbackService;

    @PostMapping("/submit")
    @ApiOperation("提交用户反馈")
    public Result submit(@RequestBody SubmitDTO submitDTO){
        log.info("提交用户反馈:{}",submitDTO);
        feedbackService.submit(submitDTO);
        return Result.success("提交成功！");
    }


    @GetMapping("/list")
    @ApiOperation("获取用户反馈列表")
    public Result<PageResult> list(UserPageDTO userPageDTO){
        log.info("获取用户反馈列表:{}",userPageDTO);
        try {
            PageResult pageResult = feedbackService.list(userPageDTO);
            return Result.success(pageResult,"查询成功！");
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }
}
